package IntSet;

import static IntSet.IntSet.*;

public class Main {
    public static void main(String[] args) {
        IntSet intSet = new IntSet();
        intSet.insert(50);        // 插入 int16 值
        intSet.insert(200);       // 插入 int16 值
        intSet.insert(1000);      // 插入 int16 值
        intSet.insert(50000);     // 插入 int32 值，触发升级
        intSet.insert(300000L);   // 插入 int64 值，触发升级

        Object allData = intSet.getAllData();
        switch (intSet.getEncoding()) {
            case INTSET_ENC_INT16:
                short[] allData1 = (short[]) allData;
                for (short data : allData1) {
                    System.out.println(data);
                }
                break;
            case INTSET_ENC_INT32:
                int[] allData2 = (int[]) allData;
                for (int data : allData2) {
                    System.out.println(data);
                }
                break;
            case INTSET_ENC_INT64:
                long[] allData3 = (long[]) allData;
                for (long data : allData3) {
                    System.out.println(data); // [50, 200, 1000, 50000, 300000]
                }
        }

        int index1 = intSet.find(1000);
        int index2 = intSet.find(200000L);
        System.out.println(index1); // 2
        System.out.println(index2); // -1
    }
}
